const Koa = require('koa')
const Router = require('@koa/router')
const {koaBody} = require('koa-body')
const {_login,_getlist,_delete,_update, _addlist,_batchdeletion,_getSelectList,_sendCode,_updatePassword}  = require('./controller/index')
// ld
const {_getsecurity,_deletesecurity,_updatesecurity,_addsecurity,_BatchdeletionSecurity,_selectsecurity,} = require('./controller/security')
// dxp
const {_getBase,_deleteBase, _addBase,_updataBase, SelectBase} =require('./controller/Base')
const app = new Koa();
const router = new Router();
app.use(async(ctx,next)=>{
    ctx.set('Access-Control-Allow-Origin', 'http://localhost:5174');
    await next()
})
app.use(koaBody())
// 登录的接口
router.post('/api/login',_login)

// 页面一

// 获取数据列表接口
router.get('/api/getlist',_getlist)
// 根据id删除数据的接口
router.delete('/api/delete',_delete)
// 根据id修改数据接口
router.put('/api/editlist',_update)
// 添加的接口
router.post('/api/addlist',_addlist)
// 批量删除数据的接口
router.post('/api/batchdeletion',_batchdeletion)
// 查询接口
router.get('/api/getSelectList',_getSelectList)
// 上传
router.post('/api/upload')
// 发送验证码
router.post('/api/sendcode',_sendCode)
// 修改密码
router.post('/api/ChangePassword',_updatePassword)


// 页面二


// 页面三ss
// 获取数据
router.get('/api/getsecurity',_getsecurity)
// 删除数据
router.delete('/api/deletesecurity',_deletesecurity)
// 根据id修改数据
router.put('/api/editsecurity',_updatesecurity)
// 添加数据
router.post('/api/addsecurity',_addsecurity)
// 批量删除数据
router.post('/api/batchdeletionsecurity',_BatchdeletionSecurity)
// 查询数据
router.get('/api/selectsecurity',_selectsecurity)


// dxp
// 获取数据呢
router.get('/api/getBase',_getBase)
// 删除数据
router.delete('/api/deleteBase',_deleteBase)
// 添加数据
router.post('/api/addBase',_addBase)
// 根据Id修改
router.put('/api/updateBase',_updataBase)
// 搜索
router.get('/api/SelectBase',SelectBase)
app.use(router.routes())







app.listen(9000,()=>{
    console.log('port:http://localhost:9000');
})

